package com.zhuiyun.project.api.plan.fitnessAction.controller;

import com.zhuiyun.project.annotation.OptLog;
import com.zhuiyun.project.api.plan.fitnessAction.entity.FitnessAction;
import com.zhuiyun.project.api.plan.fitnessAction.mapper.FitnessActionMapper;
import com.zhuiyun.project.api.plan.fitnessAction.model.FitnessActionModel;
import com.zhuiyun.project.api.plan.fitnessAction.service.FitnessActionService;
import com.zhuiyun.project.api.plan.fitnessType.entity.FitnessType;
import com.zhuiyun.project.api.plan.fitnessType.service.FitnessTypeService;
import com.zhuiyun.project.common.errorCode.CommonException;
import com.zhuiyun.project.common.response.CommonResult;
import com.zhuiyun.project.utils.constants.CommonConstants;
import com.zhuiyun.project.utils.pageUtil.PageRequest;
import com.zhuiyun.project.utils.pageUtil.PageResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName FitnessActionController
 * @Description TODO
 * @Author ys
 * @Date 2023/11/2 8:48
 **/
@RestController
@RequestMapping("/plan")
public class FitnessActionController {
    @Autowired
    private FitnessActionService fitnessActionService;

    @Resource
    FitnessActionMapper fitnessActionMapper;

    /**
     * @Author zuo
     * @Description todo 健身动作查询
     * @Date 2023/11/2 9:28
     * @Return  * @param null
     */
    @ApiOperation(value = "健身动作查询q")
    @OptLog(modular = "健身动作列表q", type = CommonConstants.SELECT, describe = "健身动作查询q ")
    @GetMapping("/getFitnessActionall")
    public CommonResult selectAlll(){

        return CommonResult.ok(fitnessActionService.selectAlll());
    }


    /**
    * @Author 杨珅
    * @Description todo 健身动作查询
    * @Date 2023/11/2 9:28
    * @Return  * @param null
    */
    @PreAuthorize("@ss.hasPermi('plan:fitnessAction')")
    @ApiOperation(value = "健身动作查询")
    @OptLog(modular = "健身动作列表", type = CommonConstants.SELECT, describe = "健身动作查询 ")
    @GetMapping("/getFitnessAction")
    public CommonResult selectAll(PageRequest pageRequest, String fitnessActionName,String venueUniqueIdentifier,Integer fitnessPurposeId){
        PageResult pageResult = fitnessActionService.selectAll(pageRequest,fitnessActionName,venueUniqueIdentifier,fitnessPurposeId);
        return CommonResult.ok(pageResult);
    }
    /**
     * @Author 杨珅
     * @Description todo 根据健身部位名和目的查询动作
     * @Date 2023/11/2 9:28
     * @Return  * @param null
     */
    @PreAuthorize("@ss.hasPermi('plan:fitnessAction')")
    @ApiOperation(value = "健身动作查询")
    @OptLog(modular = "健身动作列表", type = CommonConstants.SELECT, describe = "健身动作查询 ")
    @GetMapping("/queryFitnessAction")
    public CommonResult queryAll(String venueUniqueIdentifier,Integer fitnessPurposeId,String fitnessTypeName){
        return CommonResult.ok(fitnessActionService.queryAll(venueUniqueIdentifier,fitnessPurposeId,fitnessTypeName));
    }
    /**
     * @Author 杨珅
     * @Description todo 根据健身部位id和目的查询动作
     * @Date 2023/11/2 9:28
     * @Return  * @param null
     */
    @PreAuthorize("@ss.hasPermi('plan:fitnessAction')")
    @ApiOperation(value = "健身动作查询")
    @OptLog(modular = "健身动作列表", type = CommonConstants.SELECT, describe = "健身动作查询 ")
    @GetMapping("/queryByType")
    public CommonResult queryByType(String venueUniqueIdentifier,Integer fitnessPurposeId){
        return CommonResult.ok(fitnessActionService.queryByType(venueUniqueIdentifier,fitnessPurposeId));
    }
    /**
     * @Author 杨珅
     * @Description todo 根据健身部位id和目的查询动作（分页版）
     * @Date 2023/11/2 9:28
     * @Return  * @param null
     */
    @PreAuthorize("@ss.hasPermi('plan:fitnessAction')")
    @ApiOperation(value = "健身动作查询")
    @OptLog(modular = "健身动作列表", type = CommonConstants.SELECT, describe = "健身动作查询 ")
    @GetMapping("/queryByTypes")
    public CommonResult queryByTypes(PageRequest pageRequest,String venueUniqueIdentifier,Integer fitnessPurposeId,Integer fitnessTypeId){
        return CommonResult.ok(fitnessActionService.queryByTypes(pageRequest,venueUniqueIdentifier,fitnessPurposeId,fitnessTypeId));
    }
    /**
     * @Author 杨珅
     * @Description todo 健身类型查询
     * @Date 2023/11/2 9:28
     * @Return  * @param null
     */
    @PreAuthorize("@ss.hasPermi('plan:fitnessAction')")
    @ApiOperation(value = "健身类型查询")
    @OptLog(modular = "健身动作列表", type = CommonConstants.SELECT, describe = "健身类型查询 ")
    @GetMapping("/getFitnessTypeAll")
    public CommonResult selectTypeAll(PageRequest pageRequest,Integer id){
        return CommonResult.ok(fitnessActionService.selectTypeAll(pageRequest,id));
    }
    /**
     * @Author 杨珅
     * @Description todo 健身目的查询
     * @Date 2023/11/2 9:28
     * @Return  * @param null
     */
    @PreAuthorize("@ss.hasPermi('plan:fitnessAction')")
    @ApiOperation(value = "健身类型查询")
    @OptLog(modular = "健身动作列表", type = CommonConstants.SELECT, describe = "健身类型查询 ")
    @GetMapping("/getFitnessPurposeAll")
    public CommonResult selectPurposeAll(String venueUniqueIdentifier){
        return CommonResult.ok(fitnessActionService.selectPurposeAll(venueUniqueIdentifier));
    }
    /**
     * @Author 杨珅
     * @Description todo 健身器材查询
     * @Date 2023/11/2 9:28
     * @Return  * @param null
     */
    @PreAuthorize("@ss.hasPermi('plan:fitnessAction')")
    @ApiOperation(value = "健身类型查询")
    @OptLog(modular = "健身动作列表", type = CommonConstants.SELECT, describe = "健身类型查询 ")
    @GetMapping("/getFitnessEquipmentAll")
    public CommonResult selectEquipmentAll(String venueUniqueIdentifier){
        return CommonResult.ok(fitnessActionService.selectEquipmentAll(venueUniqueIdentifier));
    }
    /**
     * @Author 杨珅
     * @Description todo 健身动作新增
     * @Date 2023/11/2 9:28
     * @Return  * @param null
     */
    @PreAuthorize("@ss.hasPermi('plan:fitnessAction')")
    @ApiOperation(value = "健身动作新增")
    @OptLog(modular = "健身动作列表", type = CommonConstants.ADD, describe = "健身动作新增 ")
    @PostMapping("/addFitnessAction")
    public CommonResult insertFitnessAction(FitnessActionModel fitnessAction)throws CommonException {
        return CommonResult.ok(fitnessActionService.insertFitnessAction(fitnessAction));
    }
    /**
     * @Author 杨珅
     * @Description todo 健身图片新增
     * @Date 2023/11/2 9:28
     * @Return  * @param null
     */
    @PreAuthorize("@ss.hasPermi('plan:fitnessAction')")
    @ApiOperation(value = "健身动作新增")
    @OptLog(modular = "健身动作列表", type = CommonConstants.ADD, describe = "健身动作新增 ")
    @PostMapping("/insertImg")
    public CommonResult insertImg(MultipartFile file){
        return CommonResult.ok(fitnessActionService.insertImg(file));
    }
    /**
     * @Author 杨珅
     * @Description todo 健身动作修改
     * @Date 2023/11/2 9:28
     * @Return  * @param null
     */
    @PreAuthorize("@ss.hasPermi('plan:fitnessAction')")
    @ApiOperation(value = "健身动作修改")
    @OptLog(modular = "健身动作列表", type = CommonConstants.UPDATE, describe = "健身动作修改 ")
    @PostMapping("/updateFitnessAction")
    public CommonResult updateFitnessAction(FitnessActionModel fitnessAction) throws CommonException{
        return CommonResult.ok(fitnessActionService.updateFitnessAction(fitnessAction));
    }
    /**
     * @Author 杨珅
     * @Description todo 健身动作删除
     * @Date 2023/11/2 9:28
     * @Return  * @param null
     */
    @PreAuthorize("@ss.hasPermi('plan:fitnessType')")
    @ApiOperation(value = "健身动作删除")
    @OptLog(modular = "健身动作列表", type = CommonConstants.DELETE, describe = "健身动作删除 ")
    @DeleteMapping("/deleteFitnessAction")
    public CommonResult deleteFitnessAction(@RequestBody FitnessActionModel fitnessAction){
        return CommonResult.ok(fitnessActionService.deleteFitnessAction(fitnessAction));
    }

    /*
    * @Author xy
    * @Description todo 测试sql拦截器查询
    * @Date 2023/12/8 11:24
    * @Return
    * @param
    */
    @GetMapping("/testAction")
    public CommonResult test(){
        fitnessActionMapper.selectList(null);
        return CommonResult.ok();
    }
}
